home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2710 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  981 b 

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Floating point calculation order
  5. Date: Tue, 23 Jan 1996 11:32:31 GMT
  6. Organization: Netcom
  7. Message-ID: <3104c6d9.134061184@nntp.ix.netcom.com>
  8. References: <m0tedv8-0002eqC@sice.nsk.su>
  9. NNTP-Posting-Host: ix-dc6-08.ix.netcom.com
  10. X-NETCOM-Date: Tue Jan 23  3:31:59 AM PST 1996
  11. X-Newsreader: Forte Agent .99c/16.141
  12.  
  13. "Pavel A. Zemtsov" <PZEM@sice.nsk.su> wrote:
  14.  
  15. >  Having declaration
  16. >  double x, p, q, r;
  17. > my compiler (cc on SCO 3.2) calculated following expression:
  18. >  x = p * q / r;
  19. > as p * (q/r); (I mean, it divided first, than multiplied). That 
  20. > resulted in precision loss.
  21. > Is this legal behavior?
  22.  
  23. Not in ANSI C, but it was legal in K&R. If memory serves, it was not
  24. made illegal until very late in the standardizattion process so if
  25. your compiler was written before the standard was finalized it may not
  26. adhere to this.
  27.  
  28. Michael M Rubenstein
  29.